package com.hightrast.service.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hightrast.service.api.baseEntity.R;
import com.hightrast.service.api.domain.qo.rastProducts.QueryProductCountQo;
import com.hightrast.service.api.domain.qo.rastProducts.QueryRastProductsQo;
import com.hightrast.service.api.domain.qo.rastProducts.UpdateProductQo;
import com.hightrast.service.api.domain.vo.rastOrderItem.QueryCountChartData;
import com.hightrast.service.api.domain.vo.rastProduct.QueryRastProductsVo;
import com.hightrast.service.service.IRastProductVariantsService;
import com.hightrast.service.service.IRastProductsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author hx
 * @since 2025-01-22
 */
@RestController
@RequestMapping("/api/rast-products")
@Api(tags = "商品")
public class RastProductsController {

    @Resource
    IRastProductsService productService;
    @Resource
    IRastProductVariantsService variantsService;

    @ApiOperation("查询商品列表")
    @PostMapping("/queryProducts")
    public R<IPage<QueryRastProductsVo>> queryProducts(@RequestBody @Validated QueryRastProductsQo qo) {
        return R.data(productService.queryProducts(qo));
    }

    @ApiOperation("修改商品信息")
    @PostMapping("/updateProducts")
    public R<Void> updateProducts(@RequestBody @Validated UpdateProductQo qo) {
        productService.updateProducts(qo);
        return R.success();
    }

    @ApiOperation("查询商品变体标题")
    @GetMapping("/queryVariantsTitle")
    public R<List<String>> queryVariantsTitle() {
        return R.data(variantsService.queryVariantsTitle());
    }

    @ApiOperation("查询商品类型")
    @GetMapping("/queryProductType")
    public R<List<String>> queryProductType() {
        return R.data(productService.queryProductType());
    }

    @ApiOperation("商品销售数据统统计")
    @PostMapping("/queryProductCount")
    public R<QueryCountChartData> queryProductCount(@RequestBody @Validated QueryProductCountQo qo) {
        return R.data(productService.queryProductCount(qo));
    }
}
